# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=phpldapadmin
pkgver=1.2.6.6
pkgrel=1
pkgdesc="A PHP and hence web-based tool to administrate LDAP over the WWW"
arch=('any')
url="https://github.com/leenooks/phpLDAPadmin"
license=('GPL')
depends=('libldap' 'php')
makedepends=('optipng')
backup=("etc/webapps/phpldapadmin/config.php")
source=($pkgname-$pkgver.tar.gz::https://github.com/leenooks/phpLDAPadmin/archive/$pkgver.tar.gz
	disable-mcrypt.patch
	sort-in-templates.patch
	more-php8-fixes.patch)
sha256sums=('7a8c02a611e60aa6713d1cf863dfac9637e23c3f4d401ea5e47dbe2b22d4895a'
            'b31774abab4dd603ec9acbeda49adb188890173ee93042a811b5724e01edd837'
            'fc2d4bdf4d43a90aa541fe20eeed494caa339eacf3f08b06539efcdbacc3578f'
            '57e52f6a78c13ac231bc667932f2cde3d6d9dfa17b7011fb1ab6ab2ce0b966c1')

prepare() {
  cd "$srcdir"/phpLDAPadmin-${pkgver}/
  find -type f -name '*.png' -exec optipng -quiet -force -fix {} \;
  patch -p1 -i "$srcdir"/disable-mcrypt.patch
  patch -p1 -i "$srcdir"/sort-in-templates.patch
  patch -p1 -i "$srcdir"/more-php8-fixes.patch
  find -type f -name '*.orig' -exec rm -f {} \;
}

package() {
  _instdir="$pkgdir"/usr/share/webapps/phpldapadmin
  mkdir -p ${_instdir} "$pkgdir"/etc/webapps/phpldapadmin
  cd ${_instdir}

  cp -ra "$srcdir"/phpLDAPadmin-${pkgver}/* .

  ln -s /etc/webapps/phpldapadmin/config.php ${_instdir}/config/config.php
  cp ${_instdir}/config/config.php.example "$pkgdir"/etc/webapps/phpldapadmin/config.php
}
